<template>
    <div v-if="hasPermissions('paidan')">
        <square-button :title="title" v-on="$listeners" v-bind="$attrs"
                       @click="showDialog" icon="el-icon-s-promotion" class="agree-button"></square-button>
        <approver-list :visible.sync="visible" v-if="visible" @callback="toNext" :data-list="dataList"  :showCheckbox="showCheckbox"></approver-list>
    </div>

</template>
<script>
    import workManagement from "@/api/workManagement/index";
    import fixer from "@/api/fixer/index"
    import SquareButton from "@/components/WorkFlowsDialog/Case/SquareButton";
    import ApproverList from "@/components/WorkFlowsDialog/Case/ApproverList";
    import eventBus from "@/utils/eventBus";
    export default {
        name: "dispatchButton",
        components: {ApproverList, SquareButton},
        props: {
            title: {
                type: String,
                default: "派单"
            },
            row:{
                type:Object,
                default: function () {
                    return {}
                }
            }
        },
        data() {
            return {
                visible:false,
                showCheckbox:false,
                dataList:[]
            }
        },
        created() {
        },
        mounted() {

        },
        methods:{
            showDialog(){
                fixer.getFixer().then(res=>{
                    this.dataList = res.data
                    this.visible=true
                    this.showCheckbox = false
                })
            },
            toNext(node) {
                workManagement.changTicketsStatus(this.row.ticket,{state_id:7,type_id:0,act_state_id:1,participant:node.username}).then(res=>{
                    this.msgSuccess("处理成功！");
                    this.visible = false
                    eventBus.$emit("closeDetailDialog",true)
                })
            },
        }
    }
</script>
<style lang="scss" scoped>
.agree-button{
  background-color: #04a65b;
  color: #fff;
  border-color: #04a65b;
}
    @import "~@/styles/variables.scss";
    .show{
        background-color: $fixedMenuBg;
        color: white;
    }
    .hide{
        background-color: #e0e0e0;
        color: #666666;
    }
    .active-button {
        width: 70px;
        height: 70px;
        position: absolute;
        right: 0px;
        bottom: 40px;
        border-top-left-radius: 35px;
        border-bottom-left-radius: 35px;
        i {
            padding-left: 25px;
            padding-top: 20px;
            font-size: 24px;
        }
    }
</style>
